package com.hongkuncheng.cms.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hongkuncheng.cms.helper.PageHelper;
import org.springframework.web.servlet.HandlerInterceptor;

public class AdminLoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        if (request.getSession().getAttribute("admin") == null) {
            PageHelper.redirectToTop("/admin/login");
            return false;
        }
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }

}
